package com.qying.myguava.util;

import java.util.*;
import java.util.stream.Stream;
import java.util.stream.StreamSupport;

public interface MyCollection<E> extends MyIterable<E>{

    int size();

    boolean isEmpty();

    boolean contains(Object o);

    MyIterator<E> iterator();

    Object[] toArray();

    <T> T[] toArray(T[] a);

    boolean add(E e);

    boolean remove(Object o);

    boolean containsAll(MyCollection<?> c);

    boolean addAll(MyCollection<? extends E> c);

    boolean removeAll(MyCollection<?> C);

    default boolean removeIf(MyPredicate<? super  E> filter){
        Objects.requireNonNull(filter);

        boolean removed = false;
        final MyIterator<E> each = iterator();

        while (each.hasNext()) {
            if (filter.test(each.next())) {
                each.remove();
                removed = true;
            }
        }
        return removed;
    }

    boolean retailAll(MyCollection<?> c);

    void clear();

    boolean equals(Object o);

    int hashCode();

    default Spliterator<E> spliterator(){
        return null;
        //return Spliterators.spliterator(this , 0);
    }

    default Stream<E> stream() {
        return StreamSupport.stream(spliterator(), false);
    }

    default Stream<E> parallelStream(){
        return StreamSupport.stream(spliterator(), true);
    }


}
